<!-- 经典布局 -->
<template>
  <el-container class="layout">
    <el-header>
      <div class="header-lf mask-image">
        <div class="logo flx-center">
          <img class="logo-img" src="@/assets/images/logo.svg" alt="logo" />
          <span class="logo-text">{{ title }}</span>
        </div>
        <ToolBarLeft />
      </div>
      <div class="header-ri">
        <ToolBarRight />
      </div>
    </el-header>
    <el-container class="classic-content">
      <el-aside>
        <div class="aside-box" :style="{ width: isCollapse ? '65px' : '210px' }">
          <el-scrollbar>
            <el-menu
              :default-active="activeMenu"
              :router="false"
              :collapse="isCollapse"
              :collapse-transition="false"
              :unique-opened="true"
            >
              <SubMenu :menu-list="menuList" />
            </el-menu>
            <!--            <div v-for="subItem in menuList" :key="subItem.path" style="padding: 10px; border: 1px solid black">-->
            <!--              <div @click="clickMenu(subItem)">-->
            <!--                <el-icon> <component :is="subItem.meta.icon"></component> </el-icon>{{ subItem.meta.title }}-->
            <!--              </div>-->
            <!--            </div>-->
          </el-scrollbar>
          <!--          <el-scrollbar>-->
          <!--            <div-->
          <!--              v-for="subItem in childrenMenu"-->
          <!--              :key="subItem.path"-->
          <!--              style="padding: 10px; border: 1px solid red"-->
          <!--              @click="clickChildren(subItem)"-->
          <!--            >-->
          <!--              {{ subItem.meta!.title }}-->
          <!--            </div>-->
          <!--          </el-scrollbar>-->
        </div>
      </el-aside>
      <el-container class="classic-main">
        <Main />
      </el-container>
    </el-container>
  </el-container>
</template>

<script setup lang="ts" name="layoutClassic">
  import { computed, ref } from "vue"
  import { useRoute, useRouter } from "vue-router"
  import { useAuthStore } from "@/stores/modules/auth"
  import { useGlobalStore } from "@/stores/modules/global"
  import Main from "@/layouts/components/Main/index.vue"
  import SubMenu from "@/layouts/components/Menu/SubMenu.vue"
  import ToolBarLeft from "@/layouts/components/Header/ToolBarLeft.vue"
  import ToolBarRight from "@/layouts/components/Header/ToolBarRight.vue"

  const title = import.meta.env.VITE_GLOB_APP_TITLE

  const route = useRoute()
  const authStore = useAuthStore()
  const globalStore = useGlobalStore()
  const isCollapse = computed(() => globalStore.isCollapse)
  const menuList = computed(() => authStore.showMenuListGet)
  const activeMenu = computed(() => (route.meta.activeMenu ? route.meta.activeMenu : route.path) as string)

  // let childrenMenu = ref([]);
  // const router = useRouter();
  // function clickMenu(e) {
  //   console.log(e);
  //   if (e.meta.isLink) return window.open(e.meta.isLink, "_blank");
  //   if (e.meta.isFull) {
  //     router.push(e.path);
  //   }
  //   if (e.children) {
  //     childrenMenu.value = e.children;
  //   } else {
  //     childrenMenu.value = [];
  //   }
  // }
  // function clickChildren(subItem) {
  //   router.push(subItem.path);
  // }
</script>

<style scoped lang="scss">
  @import "./index.scss";
</style>
